package org.example.myleet.rosalind.utils;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

public class AminoAcidMassReader {

    //https://rosalind.info/glossary/monoisotopic-mass-table/
    private static final String MONOISOTOPIC_MASS_TABLE = "" +
            "A   71.03711\n" +
            "C   103.00919\n" +
            "D   115.02694\n" +
            "E   129.04259\n" +
            "F   147.06841\n" +
            "G   57.02146\n" +
            "H   137.05891\n" +
            "I   113.08406\n" +
            "K   128.09496\n" +
            "L   113.08406\n" +
            "M   131.04049\n" +
            "N   114.04293\n" +
            "P   97.05276\n" +
            "Q   128.05858\n" +
            "R   156.10111\n" +
            "S   87.03203\n" +
            "T   101.04768\n" +
            "V   99.06841\n" +
            "W   186.07931\n" +
            "Y   163.06333\n";

    public static Map<String, BigDecimal> getAminoAcidMassMap() {
        Map<String, BigDecimal> aminoAcidMapMass = new HashMap<>(20);
        String[] lines = MONOISOTOPIC_MASS_TABLE.split("\n");
        for (String line : lines) {
            String aa = line.substring(0, 1);
            String mass = line.substring(4);
            aminoAcidMapMass.put(aa, new BigDecimal(mass));
        }
        return aminoAcidMapMass;
    }
}
